// MoveNozzleCommand.cpp: implementation of the MoveNozzleCommand class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "MoveNozzleCommand.h"
#include "Nozzle.h"
#include "NozzleSelector.h"
#include "NozzleGeometry.h"
#include "StraightNozzle.h"
#include "Interact.h"
#include "CommandModuleRes.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

MoveNozzleCommand::MoveNozzleCommand()
{

}

MoveNozzleCommand::~MoveNozzleCommand()
{
	
}

BOOL MoveNozzleCommand::Execute()
{
	Nozzle* pNozzle = this->GetSelectedNozzle();
	if (pNozzle == NULL)
	{
		return FALSE;
	}

	StdString strPrompt;
	AcGePoint3d basePoint,endPoint;
	strPrompt.LoadString(COMMAND_MOVE_BASEPOINT);
	BOOL bflag = CInteract::GetPoint(strPrompt,
		basePoint);
	if (bflag == FALSE)
	{
		return FALSE;
	}

	strPrompt.LoadString(COMMAND_MOVE_ENDPOINT);
	bflag = CInteract::GetPoint(basePoint,
		strPrompt, endPoint);
	if (bflag == FALSE)
	{
		return FALSE;
	}
	
	AcGeMatrix3d xform;
	xform.setTranslation(endPoint.asVector());

	pNozzle->TransformBy(xform);
	
	return TRUE;
}	

Nozzle* MoveNozzleCommand::GetSelectedNozzle()
{
	NozzleSelector select;
	if( select.Select())
	{
		return select.GetSelected();
	}
	else
	{
		return NULL;
	}
}